/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastroNotaFiscal2.java
 *
 * Created on 05/04/2011, 03:17:11
 */
package Tela;

import Classe.BD;
import Classe.Cliente;
import Classe.ClientePJ;
import Classe.Marca;
import Classe.Modelo;
import Classe.Orcamento;
import Classe.Peca;
import Classe.PecaHasOrcamento;
import Classe.Validacao;
import Classe.Veiculo;
import java.awt.Component;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import localizarInserir.LocalizarClienteInserir;
import localizarInserir.LocalizarClienteJuridicoInserir;
import localizarInserir.LocalizarPecaInserir;
import localizarInserir.VeiculoOrcamento;

/**
 *
 * @author gladson
 */
public class CadastroOrcamento extends Validacao {

    private Component frameI;

    /** Creates new form CadastroNotaFiscal2 */
    public CadastroOrcamento() {
        initComponents();
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        iniciar();
    }
    int veiculoincluso = 0;
    int tipoCliente = 0;
    Double precoTotalPeca;
    Double valorTotNota;
    Veiculo veiculo;
    Marca marca;
    Modelo modelo;
    Cliente cli;
    ClientePJ clipj;

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        pnlCadastroNotaFiscal = new javax.swing.JPanel();
        jTabbedPaneNF = new javax.swing.JTabbedPane();
        pnlDestinatarioRemetente = new javax.swing.JPanel();
        pnlDestinatarioRemetenteNotaFiscal = new javax.swing.JPanel();
        rdPessoaFisicaNotaFiscal = new javax.swing.JRadioButton();
        rdPessoaJuridicaNotaFiscal = new javax.swing.JRadioButton();
        lblNomeRazaoNotaFiscal = new javax.swing.JLabel();
        lblCnpjCpfNotaFiscal = new javax.swing.JLabel();
        sTxtRazaSocJuridico = new javax.swing.JTextField();
        sTxtCnpjJuridico = new javax.swing.JFormattedTextField();
        lblTelefoneFaxNotaFiscal = new javax.swing.JLabel();
        sTxtContatoJuridico = new javax.swing.JTextField();
        txtTelJuridico = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        pnlEnderecoNotaFiscal = new javax.swing.JPanel();
        lblRuaAvenidaNotaFiscal = new javax.swing.JLabel();
        iTxtNumeroCliente = new javax.swing.JTextField();
        lblNumeroNotaFiscal = new javax.swing.JLabel();
        lblBairroNotaFiscal = new javax.swing.JLabel();
        lblCidadeNotaFiscal = new javax.swing.JLabel();
        lblUfNotaFiscal = new javax.swing.JLabel();
        lblApSalaNotaFiscal = new javax.swing.JLabel();
        stxtApSalaCliente = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        stxtCEPCliente = new javax.swing.JTextField();
        TxtComplCliente = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        cbUfCliente = new javax.swing.JTextField();
        cbCidadeCliente = new javax.swing.JTextField();
        cbBairroCliente = new javax.swing.JTextField();
        txtEndCliente = new javax.swing.JTextField();
        jpnVeiculoDestinatarioPeca = new javax.swing.JPanel();
        btLocalizarVeiculoDestinatarioPeca = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        txtveiculoCliente = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtCorVeicCliente = new javax.swing.JTextField();
        txtPlacaVeiCliente = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtAnoVeiCliente = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        txtMarcaVeiCliente = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        pnlPecaNotaFilcal = new javax.swing.JPanel();
        pnlProdutoPeca = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabelaPecas = new javax.swing.JTable();
        btIncluirPeca = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        txtCodPeca = new javax.swing.JTextField();
        btExcluirPeca = new javax.swing.JButton();
        btLocPecaNF = new javax.swing.JButton();
        cbUniNF = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        txtQuantNF = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtValorUnitNF = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        pnlServNotaFilcal = new javax.swing.JPanel();
        pnlInternoServiçoNota = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        sTxtServicoNotaFiscal = new javax.swing.JTextArea();
        lblValorServicoNotaFiscal = new javax.swing.JLabel();
        txtValorServicoNotaFiscal = new javax.swing.JTextField();
        pnlObservacaoNotaFiscal1 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        stxtobsOrcamento = new javax.swing.JTextArea();
        jButton3 = new javax.swing.JButton();
        btSairNotaFiscal = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        pnlCadastroNotaFiscal.setBackground(new java.awt.Color(255, 255, 255));
        pnlCadastroNotaFiscal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, " Orçamento ", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("PMingLiU", 0, 36))); // NOI18N
        pnlCadastroNotaFiscal.setPreferredSize(new java.awt.Dimension(800, 600));

        pnlDestinatarioRemetente.setBackground(new java.awt.Color(255, 255, 255));

        pnlDestinatarioRemetenteNotaFiscal.setBackground(new java.awt.Color(255, 255, 255));
        pnlDestinatarioRemetenteNotaFiscal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Destinatário/Remetente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        buttonGroup1.add(rdPessoaFisicaNotaFiscal);
        rdPessoaFisicaNotaFiscal.setText("Pessoa Fisca");

        buttonGroup1.add(rdPessoaJuridicaNotaFiscal);
        rdPessoaJuridicaNotaFiscal.setText("Pessoa Jurídica");

        lblNomeRazaoNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblNomeRazaoNotaFiscal.setText("Nome/Razão Social");

        lblCnpjCpfNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblCnpjCpfNotaFiscal.setText("CPF/CNPJ");

        sTxtRazaSocJuridico.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        sTxtCnpjJuridico.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        lblTelefoneFaxNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblTelefoneFaxNotaFiscal.setText("Contato");

        sTxtContatoJuridico.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        txtTelJuridico.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel1.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel1.setText("Telefone");

        javax.swing.GroupLayout pnlDestinatarioRemetenteNotaFiscalLayout = new javax.swing.GroupLayout(pnlDestinatarioRemetenteNotaFiscal);
        pnlDestinatarioRemetenteNotaFiscal.setLayout(pnlDestinatarioRemetenteNotaFiscalLayout);
        pnlDestinatarioRemetenteNotaFiscalLayout.setHorizontalGroup(
            pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNomeRazaoNotaFiscal)
                            .addComponent(sTxtRazaSocJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sTxtCnpjJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblCnpjCpfNotaFiscal))
                        .addGap(18, 18, 18)
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sTxtContatoJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTelefoneFaxNotaFiscal))
                        .addGap(18, 18, 18)
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(txtTelJuridico, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)))
                    .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                        .addComponent(rdPessoaFisicaNotaFiscal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(rdPessoaJuridicaNotaFiscal)))
                .addContainerGap())
        );
        pnlDestinatarioRemetenteNotaFiscalLayout.setVerticalGroup(
            pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                        .addComponent(lblTelefoneFaxNotaFiscal)
                        .addGap(26, 26, 26))
                    .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblCnpjCpfNotaFiscal)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sTxtCnpjJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(sTxtContatoJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTelJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlDestinatarioRemetenteNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rdPessoaFisicaNotaFiscal)
                            .addComponent(rdPessoaJuridicaNotaFiscal))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblNomeRazaoNotaFiscal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sTxtRazaSocJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlEnderecoNotaFiscal.setBackground(new java.awt.Color(255, 255, 255));
        pnlEnderecoNotaFiscal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Endereço", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        lblRuaAvenidaNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblRuaAvenidaNotaFiscal.setText("Rua/Av.");

        iTxtNumeroCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        lblNumeroNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblNumeroNotaFiscal.setText("Nº.");

        lblBairroNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblBairroNotaFiscal.setText("Bairro");

        lblCidadeNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblCidadeNotaFiscal.setText("Cidade");

        lblUfNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblUfNotaFiscal.setText("UF");

        lblApSalaNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
        lblApSalaNotaFiscal.setText("Ap/Sala");

        stxtApSalaCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel2.setText("CEP");

        stxtCEPCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        TxtComplCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel3.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel3.setText("Complemento");

        cbUfCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        cbCidadeCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        cbBairroCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        txtEndCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout pnlEnderecoNotaFiscalLayout = new javax.swing.GroupLayout(pnlEnderecoNotaFiscal);
        pnlEnderecoNotaFiscal.setLayout(pnlEnderecoNotaFiscalLayout);
        pnlEnderecoNotaFiscalLayout.setHorizontalGroup(
            pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEndCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblUfNotaFiscal)
                            .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(cbUfCliente, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblRuaAvenidaNotaFiscal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbCidadeCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
                            .addComponent(lblCidadeNotaFiscal))))
                .addGap(18, 18, 18)
                .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(TxtComplCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNumeroNotaFiscal)
                            .addComponent(iTxtNumeroCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(cbBairroCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                            .addComponent(lblBairroNotaFiscal)
                            .addGap(196, 196, 196))))
                .addGap(37, 37, 37)
                .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(lblApSalaNotaFiscal)
                        .addComponent(stxtApSalaCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                        .addComponent(stxtCEPCliente))
                    .addComponent(jLabel2))
                .addGap(76, 76, 76))
        );
        pnlEnderecoNotaFiscalLayout.setVerticalGroup(
            pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stxtCEPCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblApSalaNotaFiscal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stxtApSalaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(lblBairroNotaFiscal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbBairroCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(lblUfNotaFiscal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbUfCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(lblCidadeNotaFiscal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbCidadeCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlEnderecoNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(lblRuaAvenidaNotaFiscal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtEndCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(TxtComplCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(26, 26, 26))
                            .addGroup(pnlEnderecoNotaFiscalLayout.createSequentialGroup()
                                .addComponent(lblNumeroNotaFiscal)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(iTxtNumeroCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpnVeiculoDestinatarioPeca.setBackground(new java.awt.Color(255, 255, 255));
        jpnVeiculoDestinatarioPeca.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Veículo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

        btLocalizarVeiculoDestinatarioPeca.setText("Incluir Veículo");
        btLocalizarVeiculoDestinatarioPeca.setToolTipText("Incluir Veiculo");
        btLocalizarVeiculoDestinatarioPeca.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
        btLocalizarVeiculoDestinatarioPeca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLocalizarVeiculoDestinatarioPecaActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel8.setText("Veículo");

        txtveiculoCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel9.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel9.setText("Cor");

        txtCorVeicCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        txtPlacaVeiCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel10.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel10.setText("Placa");

        txtAnoVeiCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel11.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel11.setText("Ano");

        jLabel12.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel12.setText("Marca");

        txtMarcaVeiCliente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout jpnVeiculoDestinatarioPecaLayout = new javax.swing.GroupLayout(jpnVeiculoDestinatarioPeca);
        jpnVeiculoDestinatarioPeca.setLayout(jpnVeiculoDestinatarioPecaLayout);
        jpnVeiculoDestinatarioPecaLayout.setHorizontalGroup(
            jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(txtveiculoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(txtCorVeicCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPlacaVeiCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(18, 18, 18)
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtAnoVeiCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addGap(18, 18, 18)
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtMarcaVeiCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                            .addComponent(jLabel12)))
                    .addComponent(btLocalizarVeiculoDestinatarioPeca))
                .addContainerGap())
        );
        jpnVeiculoDestinatarioPecaLayout.setVerticalGroup(
            jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                .addComponent(btLocalizarVeiculoDestinatarioPeca)
                .addGap(18, 18, 18)
                .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtveiculoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCorVeicCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnVeiculoDestinatarioPecaLayout.createSequentialGroup()
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpnVeiculoDestinatarioPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPlacaVeiCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtAnoVeiCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtMarcaVeiCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setText("Cliente PF");
        jButton1.setToolTipText("Incluir Cliente");
        jButton1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Cliente PJ");
        jButton2.setToolTipText("Incluir Cliente Jurídico");
        jButton2.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlDestinatarioRemetenteLayout = new javax.swing.GroupLayout(pnlDestinatarioRemetente);
        pnlDestinatarioRemetente.setLayout(pnlDestinatarioRemetenteLayout);
        pnlDestinatarioRemetenteLayout.setHorizontalGroup(
            pnlDestinatarioRemetenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDestinatarioRemetenteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDestinatarioRemetenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpnVeiculoDestinatarioPeca, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnlDestinatarioRemetenteLayout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2))
                    .addComponent(pnlEnderecoNotaFiscal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlDestinatarioRemetenteNotaFiscal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pnlDestinatarioRemetenteLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton1, jButton2});

        pnlDestinatarioRemetenteLayout.setVerticalGroup(
            pnlDestinatarioRemetenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDestinatarioRemetenteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDestinatarioRemetenteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlDestinatarioRemetenteNotaFiscal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlEnderecoNotaFiscal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpnVeiculoDestinatarioPeca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(32, Short.MAX_VALUE))
        );

        pnlDestinatarioRemetenteLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButton1, jButton2});

        jTabbedPaneNF.addTab("Destinatário/Remetente", pnlDestinatarioRemetente);

        pnlPecaNotaFilcal.setBackground(new java.awt.Color(255, 255, 255));

        pnlProdutoPeca.setBackground(new java.awt.Color(255, 255, 255));
        pnlProdutoPeca.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Produto(s)", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N
        pnlProdutoPeca.setPreferredSize(new java.awt.Dimension(718, 450));

        tabelaPecas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição dos Produtos", "Unid.", "Quant.", "valor unit", "Valor Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tabelaPecas);
        tabelaPecas.getColumnModel().getColumn(0).setPreferredWidth(20);
        tabelaPecas.getColumnModel().getColumn(0).setHeaderValue("Código");
        tabelaPecas.getColumnModel().getColumn(1).setPreferredWidth(262);
        tabelaPecas.getColumnModel().getColumn(1).setHeaderValue("Descrição dos Produtos");
        tabelaPecas.getColumnModel().getColumn(2).setPreferredWidth(3);
        tabelaPecas.getColumnModel().getColumn(2).setHeaderValue("Unid.");
        tabelaPecas.getColumnModel().getColumn(3).setPreferredWidth(20);
        tabelaPecas.getColumnModel().getColumn(3).setHeaderValue("Quant.");
        tabelaPecas.getColumnModel().getColumn(4).setPreferredWidth(35);
        tabelaPecas.getColumnModel().getColumn(4).setHeaderValue("valor unit");
        tabelaPecas.getColumnModel().getColumn(5).setPreferredWidth(35);
        tabelaPecas.getColumnModel().getColumn(5).setHeaderValue("Valor Total");

        btIncluirPeca.setFont(new java.awt.Font("Arial", 0, 12));
        btIncluirPeca.setText("Incluir");
        btIncluirPeca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btIncluirPecaActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Arial", 1, 11));
        jLabel4.setText("Cód. Peça");

        txtCodPeca.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        btExcluirPeca.setFont(new java.awt.Font("Arial", 0, 12));
        btExcluirPeca.setText("Excluir");
        btExcluirPeca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExcluirPecaActionPerformed(evt);
            }
        });

        btLocPecaNF.setText("Localizar Peça");
        btLocPecaNF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLocPecaNFActionPerformed(evt);
            }
        });

        cbUniNF.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
            "","CX","UNID.","PCTE","KG","GR"}));
cbUniNF.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

jLabel5.setFont(new java.awt.Font("Arial", 1, 11));
jLabel5.setText("Unidade");

txtQuantNF.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

jLabel6.setFont(new java.awt.Font("Arial", 1, 11));
jLabel6.setText("Quant.");

txtValorUnitNF.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

jLabel7.setFont(new java.awt.Font("Arial", 1, 11));
jLabel7.setText("Valor Unit.");

javax.swing.GroupLayout pnlProdutoPecaLayout = new javax.swing.GroupLayout(pnlProdutoPeca);
pnlProdutoPeca.setLayout(pnlProdutoPecaLayout);
pnlProdutoPecaLayout.setHorizontalGroup(
    pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(pnlProdutoPecaLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE)
            .addGroup(pnlProdutoPecaLayout.createSequentialGroup()
                .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtCodPeca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbUniNF, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtQuantNF, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addGroup(pnlProdutoPecaLayout.createSequentialGroup()
                        .addComponent(txtValorUnitNF, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btIncluirPeca)
                        .addGap(18, 18, 18)
                        .addComponent(btExcluirPeca)
                        .addGap(18, 18, 18)
                        .addComponent(btLocPecaNF)))))
        .addContainerGap())
    );

    pnlProdutoPecaLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cbUniNF, txtCodPeca, txtQuantNF, txtValorUnitNF});

    pnlProdutoPecaLayout.setVerticalGroup(
        pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlProdutoPecaLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel6)
                .addComponent(jLabel7)
                .addComponent(jLabel5)
                .addComponent(jLabel4))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlProdutoPecaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(txtCodPeca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(cbUniNF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(txtQuantNF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(txtValorUnitNF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(btIncluirPeca)
                .addComponent(btExcluirPeca)
                .addComponent(btLocPecaNF))
            .addGap(18, 18, 18)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 307, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(60, 60, 60))
    );

    javax.swing.GroupLayout pnlPecaNotaFilcalLayout = new javax.swing.GroupLayout(pnlPecaNotaFilcal);
    pnlPecaNotaFilcal.setLayout(pnlPecaNotaFilcalLayout);
    pnlPecaNotaFilcalLayout.setHorizontalGroup(
        pnlPecaNotaFilcalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(pnlPecaNotaFilcalLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(pnlProdutoPeca, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
            .addContainerGap())
    );
    pnlPecaNotaFilcalLayout.setVerticalGroup(
        pnlPecaNotaFilcalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlPecaNotaFilcalLayout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnlProdutoPeca, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(50, 50, 50))
    );

    jTabbedPaneNF.addTab("Peça", pnlPecaNotaFilcal);

    pnlServNotaFilcal.setBackground(new java.awt.Color(255, 255, 255));

    pnlInternoServiçoNota.setBackground(new java.awt.Color(255, 255, 255));
    pnlInternoServiçoNota.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Seviço(s)", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

    sTxtServicoNotaFiscal.setColumns(20);
    sTxtServicoNotaFiscal.setRows(5);
    sTxtServicoNotaFiscal.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    jScrollPane3.setViewportView(sTxtServicoNotaFiscal);

    lblValorServicoNotaFiscal.setFont(new java.awt.Font("Arial", 1, 11));
    lblValorServicoNotaFiscal.setText("Valor Serviço");

    txtValorServicoNotaFiscal.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

    javax.swing.GroupLayout pnlInternoServiçoNotaLayout = new javax.swing.GroupLayout(pnlInternoServiçoNota);
    pnlInternoServiçoNota.setLayout(pnlInternoServiçoNotaLayout);
    pnlInternoServiçoNotaLayout.setHorizontalGroup(
        pnlInternoServiçoNotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(pnlInternoServiçoNotaLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(pnlInternoServiçoNotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE)
                .addComponent(lblValorServicoNotaFiscal)
                .addComponent(txtValorServicoNotaFiscal, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    pnlInternoServiçoNotaLayout.setVerticalGroup(
        pnlInternoServiçoNotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlInternoServiçoNotaLayout.createSequentialGroup()
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(lblValorServicoNotaFiscal)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(txtValorServicoNotaFiscal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    pnlObservacaoNotaFiscal1.setBackground(new java.awt.Color(255, 255, 255));
    pnlObservacaoNotaFiscal1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observação", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12))); // NOI18N

    stxtobsOrcamento.setColumns(20);
    stxtobsOrcamento.setRows(5);
    stxtobsOrcamento.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    jScrollPane4.setViewportView(stxtobsOrcamento);

    javax.swing.GroupLayout pnlObservacaoNotaFiscal1Layout = new javax.swing.GroupLayout(pnlObservacaoNotaFiscal1);
    pnlObservacaoNotaFiscal1.setLayout(pnlObservacaoNotaFiscal1Layout);
    pnlObservacaoNotaFiscal1Layout.setHorizontalGroup(
        pnlObservacaoNotaFiscal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlObservacaoNotaFiscal1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 711, Short.MAX_VALUE)
            .addContainerGap())
    );
    pnlObservacaoNotaFiscal1Layout.setVerticalGroup(
        pnlObservacaoNotaFiscal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(pnlObservacaoNotaFiscal1Layout.createSequentialGroup()
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
            .addContainerGap())
    );

    javax.swing.GroupLayout pnlServNotaFilcalLayout = new javax.swing.GroupLayout(pnlServNotaFilcal);
    pnlServNotaFilcal.setLayout(pnlServNotaFilcalLayout);
    pnlServNotaFilcalLayout.setHorizontalGroup(
        pnlServNotaFilcalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlServNotaFilcalLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(pnlServNotaFilcalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(pnlObservacaoNotaFiscal1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(pnlInternoServiçoNota, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap())
    );
    pnlServNotaFilcalLayout.setVerticalGroup(
        pnlServNotaFilcalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(pnlServNotaFilcalLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(pnlInternoServiçoNota, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGap(18, 18, 18)
            .addComponent(pnlObservacaoNotaFiscal1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );

    jTabbedPaneNF.addTab("Serviço", pnlServNotaFilcal);

    jButton3.setText("Salvar");
    jButton3.setToolTipText("Salvar");
    jButton3.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    btSairNotaFiscal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    btSairNotaFiscal.setText("Sair");
    btSairNotaFiscal.setToolTipText("Sair");
    btSairNotaFiscal.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
    btSairNotaFiscal.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btSairNotaFiscalActionPerformed(evt);
        }
    });

    jButton4.setText("Limpar");
    jButton4.setToolTipText("Limpar");
    jButton4.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout pnlCadastroNotaFiscalLayout = new javax.swing.GroupLayout(pnlCadastroNotaFiscal);
    pnlCadastroNotaFiscal.setLayout(pnlCadastroNotaFiscalLayout);
    pnlCadastroNotaFiscalLayout.setHorizontalGroup(
        pnlCadastroNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(pnlCadastroNotaFiscalLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jButton3)
            .addGap(18, 18, 18)
            .addComponent(jButton4)
            .addGap(18, 18, 18)
            .addComponent(btSairNotaFiscal)
            .addContainerGap(605, Short.MAX_VALUE))
        .addComponent(jTabbedPaneNF, javax.swing.GroupLayout.DEFAULT_SIZE, 768, Short.MAX_VALUE)
    );

    pnlCadastroNotaFiscalLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btSairNotaFiscal, jButton3, jButton4});

    pnlCadastroNotaFiscalLayout.setVerticalGroup(
        pnlCadastroNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlCadastroNotaFiscalLayout.createSequentialGroup()
            .addComponent(jTabbedPaneNF, javax.swing.GroupLayout.PREFERRED_SIZE, 471, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
            .addGroup(pnlCadastroNotaFiscalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton3)
                .addComponent(jButton4)
                .addComponent(btSairNotaFiscal))
            .addContainerGap())
    );

    pnlCadastroNotaFiscalLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btSairNotaFiscal, jButton3, jButton4});

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(pnlCadastroNotaFiscal, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
            .addContainerGap())
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addComponent(pnlCadastroNotaFiscal, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-808)/2, (screenSize.height-627)/2, 808, 627);
    }// </editor-fold>//GEN-END:initComponents
    private void btSairNotaFiscalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairNotaFiscalActionPerformed
        this.dispose();
    }//GEN-LAST:event_btSairNotaFiscalActionPerformed

    private void btIncluirPecaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btIncluirPecaActionPerformed
        if (validarPeca()) {
            try {
                int codPeca = Integer.parseInt(txtCodPeca.getText().trim());
                String sql = "SELECT * FROM PECA WHERE ID_PECA=" + codPeca;

                BD banco = new BD();
                ResultSet res = banco.consultar(sql);

                DefaultTableModel model = (DefaultTableModel) tabelaPecas.getModel();

                String unidade = (String) cbUniNF.getSelectedItem();
                Double quantidade = Double.parseDouble(txtQuantNF.getText().trim());
                Double preco = Double.parseDouble(txtValorUnitNF.getText().trim());
                precoTotalPeca = preco * quantidade;

                if (res.next()) {
                    Object[] linha = {
                        res.getInt("ID_PECA"),
                        res.getString("NOME_PECA"),
                        unidade,
                        quantidade,
                        preco,
                        precoTotalPeca
                    };

                    model.addRow(linha);

                    txtCodPeca.setText("");
                    cbUniNF.setSelectedItem("");
                    txtQuantNF.setText("");
                    txtValorUnitNF.setText("");
                } else {
                    JOptionPane.showMessageDialog(rootPane, "Código de peça Inválido");
                    txtCodPeca.setText("");
                    cbUniNF.setSelectedItem("");
                    txtQuantNF.setText("");
                    txtValorUnitNF.setText("");
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_btIncluirPecaActionPerformed

    private void btLocPecaNFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLocPecaNFActionPerformed
        LocalizarPecaInserir locPecIns = new LocalizarPecaInserir();
        locPecIns.setVisible(true);
    }//GEN-LAST:event_btLocPecaNFActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        if (validar()) {
            Orcamento orc = new Orcamento();
            try {


                String sqlOrc = "SELECT SQ_ORCAMENTO.NEXTVAL AS ID_ORCAMENTO FROM DUAL";//PEGANDO O ID DE OÇAMENTO ANTES DELE SER GERADO
                BD bdIdOrc = new BD();
                ResultSet respIdOrc = bdIdOrc.consultar(sqlOrc);
                if (respIdOrc.next()) {
                    orc.setIdOrcamento(respIdOrc.getInt("ID_ORCAMENTO"));
                }
//////////////////////////////PEGANDO O VALOR TOTAL DOS PRODUTOS////////////////////////////////////////////////
                DefaultTableModel tableModel = (DefaultTableModel) tabelaPecas.getModel();
                int linhas = tableModel.getRowCount();//contando quantas colunas tem
                double totalNf = 0;
                int i = 0;
                if (linhas > 0) {
                    while (i < linhas) {
                        Double test1 = Double.parseDouble(tableModel.getValueAt(i, 5).toString());
                        totalNf = totalNf + test1;
                        i++;
                    }
                }
///////////////////////////////FIM DE PEGANDO O VALOR TOTAL DOS PRODUTOS////////////////////////////////////////



                orc.setServicoOrcamento(sTxtServicoNotaFiscal.getText().trim().toUpperCase());//servico_nf
                double serv = 0;
                if (txtValorServicoNotaFiscal.getText().trim().length() > 0) {
                    serv = Double.parseDouble(txtValorServicoNotaFiscal.getText().trim());
                }
                orc.setValorServOrcamento(serv);//valor_serv_nf

                totalNf = totalNf + serv;
                orc.setValorTotOrcamento(totalNf);//valor_tot_nf
/////////////////////PEGANDO A DATA ///////////////////////////////////////////////////////////////////////
                Date data = new Date(System.currentTimeMillis());
                SimpleDateFormat formatarDate = new SimpleDateFormat("dd/MM/yyyy");
                orc.setDataOrcamento(formatarDate.format(data));
/////////////////////////FIM DE PEGANDO A DATA//////////////////////////////////////////////////////////////
                orc.setObsOrcamento(stxtobsOrcamento.getText().trim().toUpperCase());
/////////////////////////PEGANDO A HORA ATUAL/////////////////////////////////////////////////////////////
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
                orc.setHoraOrcamento(sdf.format(data));
////////////////////////FIM DE PEGANDO A HORA ATUAL//////////////////////////////////////////////////////

                if (tipoCliente == 1) {
                    if (veiculoincluso == 0) {
                        String sql = "INSERT INTO ORCAMENTO (ID_ORCAMENTO        ,DATA_ORCAMENTO                          ,              OBS_ORCAMENTO        ,VALOR_TOT_ORCAMENTO       ,HORA_ORCAMENTO          ,ID_VEICULO             ,ID_CLIENTE         ,SERVICO_ORCAMENTO        ,VALOR_SERV_ORCAMENTO         ) "
                                + "VALUES (?                   ,TO_DATE('" + orc.getDataOrcamento() + "','DD/MM/YYYY'),?                    ,?                          ,?                      ,?                      ,?                  ,?                         ,?                           )";
                        Object[] parametros = {orc.getIdOrcamento(), orc.getObsOrcamento(), orc.getValorTotOrcamento(), orc.getHoraOrcamento(), null, cli.getIdCliente(), orc.getServicoOrcamento(), orc.getValorServOrcamento()};
                        Object[] tipos = {Integer.class, String.class, Double.class, String.class, Integer.class, Integer.class, String.class, Double.class};

                        BD banco = new BD();

                        banco.executar(sql, parametros, tipos);

                        JOptionPane.showMessageDialog(frameI, "Cadastro salvo com Sucesso");
                        this.dispose();
                        CadastroOrcamento co = new CadastroOrcamento();
                        co.setVisible(true);
                    } else {
                        String sql = "INSERT INTO ORCAMENTO (ID_ORCAMENTO        ,DATA_ORCAMENTO                          ,              OBS_ORCAMENTO        ,VALOR_TOT_ORCAMENTO       ,HORA_ORCAMENTO          ,ID_VEICULO             ,ID_CLIENTE         ,SERVICO_ORCAMENTO        ,VALOR_SERV_ORCAMENTO         ) "
                                + "VALUES (?                   ,TO_DATE('" + orc.getDataOrcamento() + "','DD/MM/YYYY'),?                    ,?                          ,?                      ,?                      ,?                  ,?                         ,?                           )";
                        Object[] parametros = {orc.getIdOrcamento(), orc.getObsOrcamento(), orc.getValorTotOrcamento(), orc.getHoraOrcamento(), veiculo.getIdVeiculo(), cli.getIdCliente(), orc.getServicoOrcamento(), orc.getValorServOrcamento()};
                        Object[] tipos = {Integer.class, String.class, Double.class, String.class, Integer.class, Integer.class, String.class, Double.class};

                        BD banco = new BD();

                        banco.executar(sql, parametros, tipos);

                        JOptionPane.showMessageDialog(frameI, "Cadastro salvo com Sucesso");
                        this.dispose();
                        CadastroOrcamento co = new CadastroOrcamento();
                        co.setVisible(true);
                    }

                } else if (tipoCliente == 2) {

                    if (veiculoincluso == 0) {
                        String sql = "INSERT INTO ORCAMENTO (ID_ORCAMENTO        ,DATA_ORCAMENTO                          ,              OBS_ORCAMENTO        ,VALOR_TOT_ORCAMENTO       ,HORA_ORCAMENTO          ,ID_VEICULO             ,ID_CLIENTE_PJ         ,SERVICO_ORCAMENTO        ,VALOR_SERV_ORCAMENTO         ) "
                                + "VALUES (?                   ,TO_DATE('" + orc.getDataOrcamento() + "','DD/MM/YYYY'),?                    ,?                          ,?                      ,?                      ,?                  ,?                         ,?                           )";
                        Object[] parametros = {orc.getIdOrcamento(), orc.getObsOrcamento(), orc.getValorTotOrcamento(), orc.getHoraOrcamento(), null, clipj.getIdClientePJ(), orc.getServicoOrcamento(), orc.getValorServOrcamento()};
                        Object[] tipos = {Integer.class, String.class, Double.class, String.class, Integer.class, Integer.class, String.class, Double.class};

                        BD banco = new BD();

                        banco.executar(sql, parametros, tipos);

                        JOptionPane.showMessageDialog(frameI, "Cadastro salvo com Sucesso");
                        this.dispose();
                        CadastroOrcamento co = new CadastroOrcamento();
                        co.setVisible(true);
                    } else {
                        String sql = "INSERT INTO ORCAMENTO (ID_ORCAMENTO        ,DATA_ORCAMENTO                          ,              OBS_ORCAMENTO        ,VALOR_TOT_ORCAMENTO       ,HORA_ORCAMENTO          ,ID_VEICULO             ,ID_CLIENTE_PJ         ,SERVICO_ORCAMENTO        ,VALOR_SERV_ORCAMENTO         ) "
                                + "VALUES (?                   ,TO_DATE('" + orc.getDataOrcamento() + "','DD/MM/YYYY'),?                    ,?                          ,?                      ,?                      ,?                  ,?                         ,?                           )";
                        Object[] parametros = {orc.getIdOrcamento(), orc.getObsOrcamento(), orc.getValorTotOrcamento(), orc.getHoraOrcamento(), veiculo.getIdVeiculo(), clipj.getIdClientePJ(), orc.getServicoOrcamento(), orc.getValorServOrcamento()};
                        Object[] tipos = {Integer.class, String.class, Double.class, String.class, Integer.class, Integer.class, String.class, Double.class};

                        BD banco = new BD();

                        banco.executar(sql, parametros, tipos);

                        JOptionPane.showMessageDialog(frameI, "Cadastro salvo com Sucesso");
                        this.dispose();
                        CadastroOrcamento co = new CadastroOrcamento();
                        co.setVisible(true);
                    }
                }

            } catch (Exception ex) {
                Logger.getLogger(CadastroOrcamento.class.getName()).log(Level.SEVERE, null, ex);
            }
/////////////////////////////////FIM DE SALVANDO A NOTA//////////////////////////////////////////////////////////




            DefaultTableModel tableModel = (DefaultTableModel) tabelaPecas.getModel();
            int linhas = tableModel.getRowCount();//contando quantas colunas tem
            int i = 0;
            if (linhas > 0) {
                while (i < linhas) {
                    try {
                        PecaHasOrcamento OrcPc = new PecaHasOrcamento();

                        OrcPc.setValorUnitOrc(Double.parseDouble(tableModel.getValueAt(i, 4).toString()));
                        OrcPc.setValorTotOrc(Double.parseDouble(tableModel.getValueAt(i, 5).toString()));
                        OrcPc.setQuantOrc(Double.parseDouble(tableModel.getValueAt(i, 3).toString()));
                        OrcPc.setUnidadeOrc(tableModel.getValueAt(i, 2).toString().toUpperCase());

                        Peca Pc = new Peca();

                        Pc.setIdPeca(Integer.parseInt(tableModel.getValueAt(i, 0).toString().toUpperCase()));

                        String sql = "INSERT INTO PECA_HAS_ORCAMENTO (ID_PECA_ORCAMENTO   ,ID_PECA       ,ID_ORCAMENTO        ,VALOR_UNID_ORC         ,VALOR_TOT_ORC         ,QUANT_ORC          ,UNID_ORC            ) "
                                + "VALUES(SQ_PECA_HAS_ORCAMENTO.NEXTVAL,?             ,?                   ,?                      ,?                     ,?                  ,?                   )";
                        System.out.print(sql);
                        Object[] parametros = {Pc.getIdPeca(), orc.getIdOrcamento(), OrcPc.getValorUnitOrc(), OrcPc.getValorTotOrc(), OrcPc.getQuantOrc(), OrcPc.getUnidadeOrc()};
                        Object[] tipos = {Integer.class, Integer.class, Double.class, Double.class, Double.class, String.class};

                        BD banco = new BD();

                        banco.executar(sql, parametros, tipos);

                        i++;
                    } catch (Exception ex) {
                        Logger.getLogger(CadastroOrcamento.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            /////////////////////////////////FIM DE PEGANDO A ULTIMA NOTA GERADA E SALVADO NA TABELA NOTA_HAS_PECA//////////


        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void btExcluirPecaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExcluirPecaActionPerformed
        ((DefaultTableModel) tabelaPecas.getModel()).removeRow(tabelaPecas.getSelectedRow());
    }//GEN-LAST:event_btExcluirPecaActionPerformed

    private void btLocalizarVeiculoDestinatarioPecaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLocalizarVeiculoDestinatarioPecaActionPerformed
        VeiculoOrcamento orc = new VeiculoOrcamento();
        if (tipoCliente == 1) {
            orc.iniciar(this, cli.getIdCliente());
        } else if (tipoCliente == 2) {
            orc.iniciarS(this, clipj.getIdClientePJ());
        }
    }//GEN-LAST:event_btLocalizarVeiculoDestinatarioPecaActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        LocalizarClienteInserir LOCCLI = new LocalizarClienteInserir(2);
        LOCCLI.recebeORC(this);
        LOCCLI.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        LocalizarClienteJuridicoInserir LOCCLIPJ = new LocalizarClienteJuridicoInserir(2);
        LOCCLIPJ.recebeORC(this);
        LOCCLIPJ.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        this.dispose();
        CadastroOrcamento co = new CadastroOrcamento();
        co.setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CadastroOrcamento().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField TxtComplCliente;
    private javax.swing.JButton btExcluirPeca;
    private javax.swing.JButton btIncluirPeca;
    private javax.swing.JButton btLocPecaNF;
    private javax.swing.JButton btLocalizarVeiculoDestinatarioPeca;
    private javax.swing.JButton btSairNotaFiscal;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField cbBairroCliente;
    private javax.swing.JTextField cbCidadeCliente;
    private javax.swing.JTextField cbUfCliente;
    private javax.swing.JComboBox cbUniNF;
    private javax.swing.JTextField iTxtNumeroCliente;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPaneNF;
    private javax.swing.JPanel jpnVeiculoDestinatarioPeca;
    private javax.swing.JLabel lblApSalaNotaFiscal;
    private javax.swing.JLabel lblBairroNotaFiscal;
    private javax.swing.JLabel lblCidadeNotaFiscal;
    private javax.swing.JLabel lblCnpjCpfNotaFiscal;
    private javax.swing.JLabel lblNomeRazaoNotaFiscal;
    private javax.swing.JLabel lblNumeroNotaFiscal;
    private javax.swing.JLabel lblRuaAvenidaNotaFiscal;
    private javax.swing.JLabel lblTelefoneFaxNotaFiscal;
    private javax.swing.JLabel lblUfNotaFiscal;
    private javax.swing.JLabel lblValorServicoNotaFiscal;
    private javax.swing.JPanel pnlCadastroNotaFiscal;
    private javax.swing.JPanel pnlDestinatarioRemetente;
    private javax.swing.JPanel pnlDestinatarioRemetenteNotaFiscal;
    private javax.swing.JPanel pnlEnderecoNotaFiscal;
    private javax.swing.JPanel pnlInternoServiçoNota;
    private javax.swing.JPanel pnlObservacaoNotaFiscal1;
    private javax.swing.JPanel pnlPecaNotaFilcal;
    private javax.swing.JPanel pnlProdutoPeca;
    private javax.swing.JPanel pnlServNotaFilcal;
    private javax.swing.JRadioButton rdPessoaFisicaNotaFiscal;
    private javax.swing.JRadioButton rdPessoaJuridicaNotaFiscal;
    private javax.swing.JFormattedTextField sTxtCnpjJuridico;
    private javax.swing.JTextField sTxtContatoJuridico;
    private javax.swing.JTextField sTxtRazaSocJuridico;
    private javax.swing.JTextArea sTxtServicoNotaFiscal;
    private javax.swing.JTextField stxtApSalaCliente;
    private javax.swing.JTextField stxtCEPCliente;
    private javax.swing.JTextArea stxtobsOrcamento;
    private javax.swing.JTable tabelaPecas;
    private javax.swing.JTextField txtAnoVeiCliente;
    private javax.swing.JTextField txtCodPeca;
    private javax.swing.JTextField txtCorVeicCliente;
    private javax.swing.JTextField txtEndCliente;
    private javax.swing.JTextField txtMarcaVeiCliente;
    private javax.swing.JTextField txtPlacaVeiCliente;
    private javax.swing.JTextField txtQuantNF;
    private javax.swing.JTextField txtTelJuridico;
    private javax.swing.JTextField txtValorServicoNotaFiscal;
    private javax.swing.JTextField txtValorUnitNF;
    private javax.swing.JTextField txtveiculoCliente;
    // End of variables declaration//GEN-END:variables

    public void iniciar() {
        rdPessoaFisicaNotaFiscal.setEnabled(false);
        sTxtRazaSocJuridico.setEnabled(false);
        sTxtCnpjJuridico.setEnabled(false);
        sTxtContatoJuridico.setEnabled(false);
        rdPessoaJuridicaNotaFiscal.setEnabled(false);
        txtTelJuridico.setEnabled(false);
        cbUfCliente.setEnabled(false);
        cbCidadeCliente.setEnabled(false);
        cbBairroCliente.setEnabled(false);
        stxtCEPCliente.setEnabled(false);
        txtEndCliente.setEnabled(false);
        TxtComplCliente.setEnabled(false);
        iTxtNumeroCliente.setEnabled(false);
        stxtApSalaCliente.setEnabled(false);
        txtveiculoCliente.setEnabled(false);
        txtCorVeicCliente.setEnabled(false);
        txtPlacaVeiCliente.setEnabled(false);
        txtAnoVeiCliente.setEnabled(false);
        txtMarcaVeiCliente.setEnabled(false);
        btLocalizarVeiculoDestinatarioPeca.setEnabled(false);
    }

    public void preencherVeiculo(Veiculo v, Modelo m, Marca mar) {
        veiculo = new Veiculo();
        marca = new Marca();
        modelo = new Modelo();

        this.veiculo = v;
        this.marca = mar;
        this.modelo = m;

        txtveiculoCliente.setText(modelo.getModelo());
        txtCorVeicCliente.setText(veiculo.getCorVeiiculo());
        txtPlacaVeiCliente.setText(veiculo.getPlacaVeiculo());
        txtAnoVeiCliente.setText(veiculo.getAnoVeiculo());
        txtMarcaVeiCliente.setText(marca.getNomeMarca());
        veiculoincluso = 1;
    }

    public void preencherOrcamentoPF(Cliente cli) {
        tipoCliente = 1;
        this.cli = new Cliente();
        this.cli = cli;
        rdPessoaFisicaNotaFiscal.setSelected(true);
        sTxtRazaSocJuridico.setText(cli.getNomePessoa());
        sTxtCnpjJuridico.setText(cli.getCpfPessoa());
        sTxtContatoJuridico.setText(cli.getNomePessoa());
        txtTelJuridico.setText(cli.getTelPessoa());
        cbUfCliente.setText(cli.getEnd().getBairroEndereco().getCidadeBairro().getEstadoCidade().getIdUf());
        cbCidadeCliente.setText(cli.getEnd().getBairroEndereco().getCidadeBairro().getNomeCidade());
        cbBairroCliente.setText(cli.getEnd().getBairroEndereco().getNomeBairro());
        stxtCEPCliente.setText(cli.getEnd().getCepEndereco());
        txtEndCliente.setText(cli.getEnd().getNomeEndereco());
        TxtComplCliente.setText(cli.getComplementoPessoa());
        iTxtNumeroCliente.setText("" + cli.getNumPessoa());
        stxtApSalaCliente.setText(cli.getApartPessoa());
        btLocalizarVeiculoDestinatarioPeca.setEnabled(true);

        veiculo = new Veiculo();
        marca = new Marca();
        modelo = new Modelo();

        txtveiculoCliente.setText(modelo.getModelo());
        txtCorVeicCliente.setText(veiculo.getCorVeiiculo());
        txtPlacaVeiCliente.setText(veiculo.getPlacaVeiculo());
        txtAnoVeiCliente.setText(veiculo.getAnoVeiculo());
        txtMarcaVeiCliente.setText(marca.getNomeMarca());

    }

    public void preencherOrcamentoPJ(ClientePJ cli) {
        tipoCliente = 2;
        clipj = new ClientePJ();
        this.clipj = cli;
        rdPessoaJuridicaNotaFiscal.setSelected(true);
        sTxtRazaSocJuridico.setText(cli.getRazaoSocialFornecedor());
        sTxtCnpjJuridico.setText(cli.getCnpjFornecedor());
        sTxtContatoJuridico.setText(cli.getContatoFornecedor());
        txtTelJuridico.setText(cli.getTelFornecedor());
        cbUfCliente.setText(cli.getEndereco().getBairroEndereco().getCidadeBairro().getEstadoCidade().getIdUf());
        cbCidadeCliente.setText(cli.getEndereco().getBairroEndereco().getCidadeBairro().getNomeCidade());
        cbBairroCliente.setText(cli.getEndereco().getBairroEndereco().getNomeBairro());
        stxtCEPCliente.setText(cli.getEndereco().getCepEndereco());
        txtEndCliente.setText(cli.getEndereco().getNomeEndereco());
        TxtComplCliente.setText(cli.getComplementoFornecedor());
        iTxtNumeroCliente.setText("" + cli.getNumFornecedor());
        stxtApSalaCliente.setText(cli.getSalaFornecedor());
        btLocalizarVeiculoDestinatarioPeca.setEnabled(true);

        veiculo = new Veiculo();
        marca = new Marca();
        modelo = new Modelo();

        txtveiculoCliente.setText(modelo.getModelo());
        txtCorVeicCliente.setText(veiculo.getCorVeiiculo());
        txtPlacaVeiCliente.setText(veiculo.getPlacaVeiculo());
        txtAnoVeiCliente.setText(veiculo.getAnoVeiculo());
        txtMarcaVeiCliente.setText(marca.getNomeMarca());


    }

    public boolean validar() {
        boolean Resultado = true;

        DefaultTableModel tableModel = (DefaultTableModel) tabelaPecas.getModel();
        int linhas = tableModel.getRowCount();//contando quantas colunas tem

        if (tipoCliente == 0) {
            JOptionPane.showMessageDialog(rootPane, "Obrigatória a seleção de um cliente ou Fornecedor!!!");
            Resultado = false;
        } else if (validarObservacao(stxtobsOrcamento.getText().trim()) == false) {
            Resultado = false;
        } else if (validarServico(sTxtServicoNotaFiscal.getText().trim(), txtValorServicoNotaFiscal.getText().trim().length()) == false) {
            Resultado = false;

        } else if (validarValorServico(txtValorServicoNotaFiscal.getText().trim(), sTxtServicoNotaFiscal.getText().trim().length()) == false) {
            Resultado = false;
        } else if (linhas == 0 && txtValorServicoNotaFiscal.getText().trim().length() == 0) {
            Resultado = false;
            JOptionPane.showMessageDialog(rootPane, "Obrigatória o preenchimento de uma Peça ou Serviço");
        }

        return Resultado;
    }

    public boolean validarPeca() {
        boolean Resultado = true;

        if (validarNumero(txtCodPeca.getText().trim()) == false) {
            Resultado = false;
        } else if (cbUniNF.getSelectedItem().equals("")) {
            JOptionPane.showMessageDialog(rootPane, "Seleção do campo 'Unidade' é Obrigatório!!");
            Resultado = false;
        } else if (validarQuant(txtQuantNF.getText().trim()) == false) {
            Resultado = false;
        } else if (validarValor(txtValorUnitNF.getText().trim()) == false) {
            Resultado = false;
        }

        return Resultado;
    }
}
